package com.polaris.live.adapter.vip

import com.bumptech.glide.Glide
import com.polaris.live.common.adapter.BaseBindingAdapter
import com.polaris.live.common.adapter.VBViewHolder
import com.polaris.live.databinding.ItemVipPrivilegesBinding
import com.polaris.live.resp.back_resp.UserVipPrivilege
import com.polaris.live.utils.VipStyle
import com.polaris.live.utils.image.ImageUtils

/**
 * VipPrivilegesAdapter  vip专属特权
 *
 * @author Created by 天晴 on 2024/12/10/031 11:44
 */
class VipPrivilegesAdapter(
    private val mLevel: Long,
) : BaseBindingAdapter<ItemVipPrivilegesBinding, UserVipPrivilege>() {

    override fun convert(
        holder: VBViewHolder<ItemVipPrivilegesBinding>,
        item: UserVipPrivilege,
    ) {
        holder.vb.apply {
            privilegesRl.setBackgroundResource(VipStyle.getVipStyle(mLevel).vipBoxPrivilegesBg)
            if (item.explain == "-1") { //为占位数据
                return
            }
            nameTv.text = item.name
            Glide.with(context)
                .load(ImageUtils.imgPath(item.icon))
                .into(privilegesImg)

            if (!item.active) {
                root.alpha = 0.3f
            }

        }
    }

}